package com.qcby.llmtchstd.controller;


import com.qcby.llmtchstd.common.ResponseResult;
import com.qcby.llmtchstd.entity.Student;
import com.qcby.llmtchstd.entity.Teacher;

import com.qcby.llmtchstd.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/teacher")
@Api(tags = "教师管理")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @RequestMapping(value = "/count",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取数量" )
    public ResponseResult count(){
        return teacherService.count();
    }

    @RequestMapping(value = "/page",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("显示教师信息" )
    public ResponseResult page(@RequestBody List<Integer> params){
        Integer page = params.get(0);
        Integer pageSize = params.get(1);
        return teacherService.page(page,pageSize);
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("添加教师信息" )
    public ResponseResult add(@RequestBody Teacher teacher){
        return teacherService.add(teacher);
    }

    @RequestMapping(value = "/search",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("查询教师信息" )
    public ResponseResult search(@RequestBody Teacher teacher){
        return teacherService.search(teacher);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("修改教师信息" )
    public ResponseResult update(@RequestBody Teacher teacher){
        return teacherService.update(teacher);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("删除教师信息" )
    public ResponseResult delete(@RequestBody Integer id){
        return teacherService.delete(id);
    }

    @RequestMapping(value = "/edit",method = RequestMethod.POST )
    @ResponseBody
    @ApiOperation("查询要修改的教师信息" )
    public ResponseResult edit(@RequestBody Integer id){
        return teacherService.edit(id);
    }

    @RequestMapping(value = "/serCount",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取搜索后的数量" )
    public ResponseResult serCount(@RequestBody Teacher teacher){
        return teacherService.serCount(teacher);
    }

}
